use wanmesh_common::error::ResponseError;

#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[error("{0}")]
    ResponseError(#[from] ResponseError),
    #[error("{0}")]
    Other(#[from] anyhow::Error),
}

impl From<wanmesh_server::http::client::error::Error> for Error {
    fn from(value: wanmesh_server::http::client::error::Error) -> Self {
        match value {
            wanmesh_server::http::client::error::Error::HttpError(e) => {
                Self::Other(anyhow::Error::new(e))
            }
            wanmesh_server::http::client::error::Error::ResponseError(e) => Self::ResponseError(e),
            wanmesh_server::http::client::error::Error::Other(e) => Self::Other(e),
        }
    }
}
